package edu.hhu.wifispark.entry;

import com.jfinal.plugin.activerecord.Model;

import edu.hhu.wifispark.util.PropUtil;

public class Caclu extends Model<Caclu>{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	public final static Caclu dao = new Caclu();
	
	public Caclu findOne(){
		return findFirst("select * from caclu");
	}
	
	public void onLoad(){
		Caclu caclu = findOne();
		PropUtil.ININ_LINE = caclu.getInt("ininline") * 60000;
		PropUtil.OUTOUT_LINE = caclu.getInt("outoutline") * 60000;
		PropUtil.ACTIVE_HIGH = caclu.getInt("activehigh") * 60000;
		PropUtil.ACTIVE_MID = caclu.getInt("activemid") * 60000;
		PropUtil.ACTIVE_LOW = caclu.getInt("activelow") * 60000;
	}
	
	public void updateStatime(String statime){
		Caclu caclu = findOne();
		caclu.set("statime", statime);
		caclu.update();
	}

	public void updateLive(int activehigh, int activemid, int activelow) {
		Caclu caclu = findOne();
		caclu.set("activehigh", activehigh);
		caclu.set("activemid", activemid);
		caclu.set("activelow", activelow);
		caclu.update();
	}

	public void updateIO(int ininline, int outoutline) {
		Caclu caclu = findOne();
		caclu.set("ininline", ininline);
		caclu.set("outoutline", outoutline);
		caclu.update();
	}
}
